﻿using ASPNETVN.PORTAL.Components.UI;
using System;
using ASPNETVN.PORTAL.Components.Helpers;
using System.Web.UI;

namespace ASPNETVN.PORTAL.Modules.FEEDBACK.Controls
{
    public partial class SendFeedback : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {                
                PORTAL.Components.Share.Category.BuildDropDownListControlForAllID(ref ddlCategory, this.ModuleID);
            }
        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            int id = Components.Item.InsertItem(this.ModuleID, txtFullName.Text, txtEmail.Text, txtAddress.Text, txtPhone.Text, txtBody.Text, DateTime.Now, txtEmail.Text, Convert.ToInt32(ddlCategory.SelectedValue));
            
            if (chkUploadFile.Checked)
            {
                string url = HttpUrlBuilder.BuildShareUrl(this.ModuleID, id, "UploadFile");
                Response.Redirect(url);
            }
            else
            {
                string url = HttpUrlBuilder.BuildModulePageUrl(this.ModuleID, this.ItemID, ModulePages.SendFeedbackCompleted);
                Response.Redirect(url);
            }
        }
    }
}